Skip to content

fix: expose entitlement guard contract metadata - #1027

Merged
kang-heewon merged 2 commits into
trunkfrom
fix/920-entitlement-guard
Jun 21, 2026
Merged

fix: expose entitlement guard contract metadata#1027
kang-heewon merged 2 commits into
trunkfrom
fix/920-entitlement-guard

Conversation

@kang-heewon

@kang-heewon kang-heewon commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

  • Connects @RequireEntitlement metadata to EntitlementGuard, including explicit tenant/user/resource/route guard input, status-aware Problems, telemetry, and optional audit sink evidence.
  • Emits entitlement requirements into contract graph snapshots and OpenAPI x-croco-entitlements, with consumer coverage and diff gates for added/removed requirements.
  • Updates entitlement result status typing, docs, public API snapshot, fixtures, and changeset.

Closes #920.

Verification

  • pnpm check
  • pnpm typecheck --filter=@croco/entitlements-core --filter=@croco/protocols-core --filter=@croco/openapi-spec --filter=@croco/access-core
  • pnpm test --filter=@croco/entitlements-core --filter=@croco/access-core --filter=@croco/protocols-core --filter=@croco/openapi-spec
  • pnpm changeset-required:check -- --base origin/trunk --head HEAD
  • git diff --check
  • Pre-push hook: pnpm test && pnpm typecheck

Self-review gates

  • Guard behavior covers no metadata, granted, denied, missing tenant, request/user tenant fallback, resource evidence, provider failure, and Problem mapping.
  • Contract artifacts cover new structured metadata, legacy prototype metadata, snapshot stability, OpenAPI extension emission, consumer coverage, and breaking diff classification.
  • Public API/docs/release metadata were regenerated and checked.

Risk

  • EntitlementCheckResult.status is now required, so fixture and downstream compile surfaces were updated with explicit states.

Summary by CodeRabbit

릴리스 노트

  • New Features

    • 엔터틀먼트 체크 결과에 상태값(allowed/denied/soft-limit/overage-allowed 등) 제공
    • 엔터틀먼트 가드가 감사(audit) 증거와 텔레메트리를 남기고, 거부 사유/문제 타입을 표준화
    • 계약 그래프에 엔터틀먼트 요구사항 반영 및 OpenAPI operation에 x-croco-entitlements 확장 포함
  • Documentation

    • 가드/라우트 사용법과 계약 아티팩트(엔터틀먼트 메타데이터) 설명 보강
  • Tests

    • 상태 필드, 감사 증거 기록, OpenAPI/계약 그래프 스냅샷·차이 검증 테스트 업데이트 및 추가

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@kang-heewon, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 18 minutes and 24 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f3ce1865-2685-4927-b769-15f65806584e

📥 Commits

Reviewing files that changed from the base of the PR and between 1f3f51f and 99b7927.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (34)
  • .changeset/entitlement-guard-contracts.md
  • examples/saas-billing-golden-path/vitest.config.ts
  • packages/admin-react/src/tests/AdminPanel.spec.ts
  • packages/cli/src/tests/contractsCheck.spec.ts
  • packages/cli/src/tests/contractsDiff.spec.ts
  • packages/cli/vitest.config.ts
  • packages/entitlements-core/README.md
  • packages/entitlements-core/package.json
  • packages/entitlements-core/src/index.ts
  • packages/entitlements-core/src/libs/EntitlementGuard.ts
  • packages/entitlements-core/src/libs/EntitlementManager.ts
  • packages/entitlements-core/src/libs/EntitlementRequirement.ts
  • packages/entitlements-core/src/libs/decorators/RequireEntitlement.ts
  • packages/entitlements-core/src/libs/interfaces.ts
  • packages/entitlements-core/src/libs/problems/EntitlementProblems.ts
  • packages/entitlements-core/src/libs/types.ts
  • packages/entitlements-core/src/tests/EntitlementGuard.spec.ts
  • packages/entitlements-core/src/tests/EntitlementIntegration.spec.ts
  • packages/entitlements-core/src/tests/EntitlementManager.spec.ts
  • packages/entitlements-core/src/tests/EntitlementRequirement.spec.ts
  • packages/framework-routes/src/__tests__/compiler.spec.ts
  • packages/openapi-spec/src/libs/emitOpenAPI.ts
  • packages/openapi-spec/src/tests/emitOpenAPI.spec.ts
  • packages/protocols-core/src/index.ts
  • packages/protocols-core/src/libs/ContractGraph.ts
  • packages/protocols-core/src/libs/ContractGraphConsumerCoverage.ts
  • packages/protocols-core/src/libs/ContractGraphDiff.ts
  • packages/protocols-core/src/libs/ContractGraphSnapshot.ts
  • packages/protocols-core/src/libs/sharedTypes.ts
  • packages/protocols-core/src/tests/ContractGraph.spec.ts
  • packages/protocols-core/src/tests/helpers/test-decorators.ts
  • packages/protocols-core/vitest.config.ts
  • packages/rpc-codegen/src/tests/codegen.spec.ts
  • public-api-surface.snapshot.json
📝 Walkthrough

Walkthrough

@RequireEntitlement 데코레이터와 EntitlementGuard가 복수 요구사항을 선언적으로 검사하도록 재구현되었다. EntitlementCheckResultstatus 유니온 필드가 추가되고, guard가 telemetry 이벤트와 EntitlementAuditSink 감사 기록을 남긴다. entitlement 요구사항은 ContractGraphSnapshotDiff → OpenAPI x-croco-entitlements 확장 필드 경로로 전파된다.

Changes

Entitlement Guard Contract Pipeline

Layer / File(s) Summary
핵심 타입 및 메타데이터 계약 정의
packages/entitlements-core/src/libs/types.ts, packages/entitlements-core/src/libs/EntitlementRequirement.ts, packages/entitlements-core/src/libs/interfaces.ts, packages/entitlements-core/src/libs/problems/EntitlementProblems.ts, packages/protocols-core/src/libs/sharedTypes.ts
EntitlementCheckStatus/EntitlementFailureReason 유니온 타입과 EntitlementCheckResult.status 필드 추가. EntitlementRequirement 타입, ENTITLEMENT_REQUIRED_KEY/ENTITLEMENT_REQUIREMENTS_KEY 키 상수, defineEntitlementRequirement·appendEntitlementRequirement·getEntitlementRequirements 함수 신설. EntitlementAuditSink 추상 클래스 및 감사 이벤트 타입 추가. Problem 서브클래스 5종(EntitlementRequirementProblem, EntitlementMissingPlanProblem, EntitlementInactiveSubscriptionProblem, EntitlementQuotaExceededProblem, EntitlementProviderUnavailableProblem) 추가.
RequireEntitlement 데코레이터 및 공개 API 확장
packages/entitlements-core/src/libs/decorators/RequireEntitlement.ts, packages/entitlements-core/src/index.ts, packages/protocols-core/src/index.ts
RequireEntitlementappendEntitlementRequirement 기반으로 재구현되어 클래스/메서드 양쪽에 적용 가능해짐. 데코레이터 반환 타입이 ClassDecorator & MethodDecorator로 확장. 두 패키지의 공개 re-export에 새 타입·함수·상수 추가.
EntitlementManager status 필드 전파
packages/entitlements-core/src/libs/EntitlementManager.ts
check()checkMetered()의 모든 반환 분기에 status 필드가 채워짐. BLOCK/WARN/ALLOW_WITH_OVERAGE overage policy별로 각각 denied/soft-limit/overage-allowed status 할당.
EntitlementGuard canActivate 다중 검사 및 증거 기록
packages/entitlements-core/src/libs/EntitlementGuard.ts
canActivategetEntitlementRequirements로 복수 요구사항을 수집해 순차 검사. 거부 시 toEntitlementProblem으로 구체적인 Problem을 throw. recordAllowed/recordDenied가 telemetry 이벤트(entitlement.guard.allowed/denied) 및 EntitlementAuditSink 기록 수행. tenantId·resource·route 해석 로직과 HTTP 컨텍스트 활용 추가.
ContractGraph entitlements 필드 및 Snapshot/Diff/Coverage 전파
packages/protocols-core/src/libs/ContractGraph.ts, packages/protocols-core/src/libs/ContractGraphSnapshot.ts, packages/protocols-core/src/libs/ContractGraphDiff.ts, packages/protocols-core/src/libs/ContractGraphConsumerCoverage.ts
ContractGraphRouteentitlements 배열 필드 추가. 스냅샷에 정렬된 entitlements 포함. diff가 requirement 추가(breaking)/제거(non-breaking) 감지. openapi 소비자는 entitlementsrequiredRouteFields에, rpc-clientunsupportedRouteFields에 등록.
OpenAPI x-croco-entitlements 확장 필드 생성 및 fingerprint
packages/openapi-spec/src/libs/emitOpenAPI.ts
toRouteConfigroute.entitlementsx-croco-entitlements 확장 필드로 변환. 커버리지 fingerprint 계산에 entitlements 포함. 결정적 정렬을 위한 compareDeclaredEntitlements·openAPIEntitlementsFingerprint 등 헬퍼 추가.
entitlements-core 테스트: Manager/Guard/Integration
packages/entitlements-core/src/tests/EntitlementManager.spec.ts, packages/entitlements-core/src/tests/EntitlementGuard.spec.ts, packages/entitlements-core/src/tests/EntitlementIntegration.spec.ts, packages/entitlements-core/src/tests/EntitlementRequirement.spec.ts, packages/admin-react/src/tests/AdminPanel.spec.ts
Manager 테스트에 status 기대값 추가. Guard 테스트에 audit/telemetry 증거 검증, Problem 매핑, provider unavailable 시나리오, audit sink 실패 처리 추가. Integration 테스트에 overage policy별 status 검증. EntitlementRequirement 테스트 신설. AdminPanel 테스트에 status 필드 추가.
protocols-core/openapi-spec 테스트 및 픽스처 업데이트
packages/protocols-core/src/tests/ContractGraph.spec.ts, packages/protocols-core/src/tests/helpers/test-decorators.ts, packages/openapi-spec/src/tests/emitOpenAPI.spec.ts, packages/cli/src/tests/contractsCheck.spec.ts, packages/cli/src/tests/contractsDiff.spec.ts, packages/framework-routes/src/__tests__/compiler.spec.ts, packages/rpc-codegen/src/tests/codegen.spec.ts
ContractGraph에 entitlement 그래프/스냅샷/diff/소비자 커버리지 테스트 신설. emitOpenAPI에 x-croco-entitlements 생성 검증 추가. test-decorators에 RequiresEntitlement 헬퍼 추가. 각 테스트 픽스처의 route 객체에 entitlements: [] 추가.
공개 API 스냅샷, changeset, vitest 설정, README
public-api-surface.snapshot.json, .changeset/entitlement-guard-contracts.md, examples/saas-billing-golden-path/vitest.config.ts, packages/cli/vitest.config.ts, packages/entitlements-core/README.md
새 런타임/타입 심볼이 스냅샷에 반영. 3개 패키지(@croco/entitlements-core, @croco/openapi-spec, @croco/protocols-core)의 patch 버전 업 changeset 기록. 예제 프로젝트 및 cli vitest 설정에서 패키지 alias 및 테스트 경로 확장. README에 guard 동작, contract artifact, status 정규화 문서화.

Sequence Diagram(s)

sequenceDiagram
  participant Client as HTTP Client
  participant Guard as EntitlementGuard
  participant Req as EntitlementRequirement
  participant Mgr as EntitlementManager
  participant Tel as Telemetry
  participant Audit as EntitlementAuditSink

  Client->>Guard: canActivate(context)
  Guard->>Req: getEntitlementRequirements(controller, handler)
  Req-->>Guard: EntitlementRequirement[]
  loop 각 requirement
    Guard->>Guard: createGuardInput(requirement, context)
    Guard->>Mgr: check(guardInput)
    Mgr-->>Guard: EntitlementCheckResult {status, granted}
    alt status: allowed
      Guard->>Tel: recordEvent(entitlement.guard.allowed, attrs)
      Guard->>Audit: recordEntitlementGuard(event)
      Audit-->>Guard: recorded
    else status: denied
      Guard->>Tel: recordEvent(entitlement.guard.denied, attrs)
      Guard->>Audit: recordEntitlementGuard(event)
      Guard-->>Client: throw Problem
    end
  end
  Guard-->>Client: true
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목은 'entitlement guard contract metadata'를 노출하는 것이 주요 변경사항임을 명확히 설명합니다.
Linked Issues check ✅ Passed PR이 #920의 모든 주요 요구사항을 충족합니다: 메타데이터 계약, 상태 유니온, 문제 매핑, 테넌트/리소스 컨텍스트, 계약 아티팩트 노출, 텔레메트리/감사 기록.
Out of Scope Changes check ✅ Passed 모든 변경사항이 entitlement guard 메타데이터 노출 목표와 직접 관련되어 있습니다: 가드 로직, 문제 타입, 계약 그래프, OpenAPI 내보내기, 테스트 픽스처 업데이트.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/920-entitlement-guard

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

github-actions Bot commented Jun 20, 2026

Copy link
Copy Markdown

📊 Benchmark Results

❌ Some benchmarks failed

Gate failures

  • CrocoApp constructor: p75 8.4μs exceeds baseline 3.4μs by more than 20%
  • CrocoApp lambdaHandler (10 controllers): p75 165.6μs exceeds baseline 33.3μs by more than 20%
  • Lambda cold-start simulation: p75 329.1μs exceeds baseline 70.2μs by more than 20%
  • Lambda cold-start with headers: p75 292.3μs exceeds baseline 66.7μs by more than 20%
  • Lambda cold-start with binary body: p75 246.2μs exceeds baseline 63.2μs by more than 20%
  • Lambda cold-start with query params: p75 214.3μs exceeds baseline 63.9μs by more than 20%
  • Lambda cold-start with authorizer context: p75 216.9μs exceeds baseline 59.8μs by more than 20%
  • Lambda cold-start realistic scenario: p75 214.5μs exceeds baseline 60.2μs by more than 20%
  • EventBusConfig.start (10 handlers): p75 1.6μs exceeds baseline 0.9μs by more than 20%
  • EventPublisher.publishNow single event: p75 1.8μs exceeds baseline 1.1μs by more than 20%
  • DefaultHandlerResolver.resolve × 10: p75 0.1μs exceeds baseline 0.0μs by more than 20%
  • Container.get singleton (cold): p75 58.5μs exceeds baseline 0.6μs by more than 20%
  • Container.register × 50 components: p75 2.7ms exceeds baseline 12.1μs by more than 20%
  • Container.validate (50 components): p75 3.0ms exceeds baseline 29.7μs by more than 20%
  • Container.get singleton (warm): p75 1.6μs exceeds baseline 0.3μs by more than 20%
  • lambdaPreset config creation: p75 1.4μs exceeds baseline 1.0μs by more than 20%
Benchmark p75 Threshold Baseline vs Baseline Status Notes
CrocoApp constructor 8.4μs 30.0ms 3.4μs +149.2% -
CrocoApp lambdaHandler (10 controllers) 165.6μs 50.0ms 33.3μs +397.5% -
Lambda cold-start simulation 329.1μs 80.0ms 70.2μs +369.0% -
Lambda cold-start with headers 292.3μs 80.0ms 66.7μs +337.9% -
Lambda cold-start with binary body 246.2μs 80.0ms 63.2μs +289.7% -
Lambda cold-start with query params 214.3μs 80.0ms 63.9μs +235.5% -
Lambda cold-start with authorizer context 216.9μs 80.0ms 59.8μs +262.8% -
Lambda cold-start realistic scenario 214.5μs 80.0ms 60.2μs +256.5% -
EventBusConfig.start (10 handlers) 1.6μs 10.0ms 0.9μs +84.2% -
EventPublisher.publishNow single event 1.8μs 2.0ms 1.1μs +68.3% -
DefaultHandlerResolver.resolve × 10 0.1μs 5.0ms 0.0μs +90.5% -
Container.get singleton (cold) 58.5μs 5.0ms 0.6μs +9259.7% -
Container.register × 50 components 2.7ms 10.0ms 12.1μs +22051.1% -
Container.validate (50 components) 3.0ms 20.0ms 29.7μs +10176.2% -
Container.get singleton (warm) 1.6μs 500.0μs 0.3μs +452.4% -
TelemetryRuntime.init (lambda preset) 1.1ms 200.0ms 69.3ms -98.4% -
lambdaPreset config creation 1.4μs 2.0ms 1.0μs +40.2% -

Updated: 2026-06-21T04:46:58.370Z · Commit: 9a8a657

@kang-heewon
kang-heewon force-pushed the fix/920-entitlement-guard branch 3 times, most recently from ee82263 to cfbbaf5 Compare June 20, 2026 07:29

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/entitlements-core/src/libs/decorators/RequireEntitlement.ts`:
- Around line 20-26: The issue is that on line 25 in the
appendEntitlementRequirement call with propertyKey, using target.constructor is
incorrect for static methods because target is already the constructor function
for static methods, making target.constructor === Function which causes metadata
to be recorded on Function instead of the actual class. To fix this, determine
whether the property is a static method or instance method and pass the correct
target: use target directly for static methods (where target is the constructor
function) and target.constructor for instance methods (where target is the
prototype). You can distinguish between static and instance methods by checking
if target is a constructor function versus a prototype object.

In `@packages/entitlements-core/src/libs/EntitlementGuard.ts`:
- Around line 217-230: The recordEntitlementGuard call on the
EntitlementAuditSink is being directly awaited, which means failures in the
audit sink can cause exceptions that override the guard result and turn allowed
requests into errors. Wrap the await call in a try-catch block so that audit
sink failures are caught and logged separately via telemetry without affecting
the original guard result. The guard should still return its decision regardless
of whether the audit sink succeeds or fails, ensuring that audit failures don't
break the entitlement check flow. Apply this isolation pattern to all
recordEntitlementGuard calls in the file including the ones referenced in the
"Also applies to" section.
- Around line 80-90: The telemetry is currently recording `problem.detail ??
problem.message` as the reason code in the span, which can contain sensitive
information like tenant identifiers or arbitrary custom strings, creating
high-cardinality telemetry. In the recordDenied method calls within the
EntitlementGuard class (at the indicated line ranges including around line
80-90, 239-241, and 310), replace the fourth parameter that passes
`problem.detail ?? problem.message` with stable reason code values instead, such
as using `result.reason ?? "not_entitled"` or constant values like
`"provider_unavailable"` to ensure only predictable, low-cardinality codes are
recorded for telemetry.
- Line 6: The import statement in EntitlementGuard.ts is mixing a value import
(getEntitlementRequirements) with an inline type import (type
EntitlementRequirement) in a single import statement. According to the
repository's TypeScript guidelines, type imports must use the separate import
type syntax. Split the import statement into two separate imports from the same
module: one regular import statement for the value getEntitlementRequirements
and one import type statement for the EntitlementRequirement type.

In `@packages/entitlements-core/src/libs/EntitlementRequirement.ts`:
- Around line 121-129: The isEntitlementRequirement function currently only
validates the feature field but does not validate the resource field structure.
This can allow invalid resource objects (where type or other properties may not
be strings) to pass through to defineEntitlementRequirement, causing runtime
TypeErrors when accessing .length on lines 144, 150, and 156. Enhance the
validation in isEntitlementRequirement to also check that the resource field
exists and has a valid shape with all required string properties (such as type)
before returning true, ensuring that only properly structured
EntitlementRequirement objects pass validation and preventing downstream errors
in the resource field access.

In `@packages/protocols-core/src/libs/ContractGraphDiff.ts`:
- Around line 179-215: The function diffEntitlementRequirements has a bug where
duplicate changes are generated when entitlements with the same fingerprint
appear multiple times in the arrays. The issue is that while the function
creates Sets for membership checking (baselineEntitlements and
currentEntitlements), it then iterates over the original arrays
(current.entitlements and baseline.entitlements) which may contain duplicates.
This causes the same change to be added multiple times to the changes array. To
fix this, instead of iterating directly over current.entitlements and
baseline.entitlements, create deduplicated collections of entitlements by their
fingerprints and iterate over those deduplicated collections instead, ensuring
each unique entitlement fingerprint is only processed once.

In `@packages/protocols-core/src/tests/helpers/test-decorators.ts`:
- Around line 97-113: The RequiresEntitlement decorator currently overwrites
existing entitlement requirements instead of accumulating them when applied
multiple times to the same target. To fix this, retrieve any existing metadata
using Reflect.getMetadata with the same ENTITLEMENT_REQUIREMENTS_KEY,
propertyKey, and target before calling Reflect.defineMetadata in both the method
decorator case (when propertyKey is provided) and the class decorator case (when
it is not). If existing metadata is found, append the new requirement to that
array before defining the metadata; otherwise, create a new array with just the
current requirement. This ensures that multiple decorator applications
accumulate requirements rather than replacing them.

In `@public-api-surface.snapshot.json`:
- Around line 3423-3430: The entries for ENTITLEMENT_REQUIRED_KEY and
ENTITLEMENT_REQUIREMENTS_KEY in the snapshot file are missing the
declarationKind field that all other const exports contain. Add
"declarationKind": "const" to both of these entries to match the structure of
other const declarations in the snapshot and ensure API validation tools can
properly categorize these exports.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6bee7cfe-1b66-4dd9-9fc8-b6727b724f2e

📥 Commits

Reviewing files that changed from the base of the PR and between 96f5c99 and ee82263.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (31)
  • .changeset/entitlement-guard-contracts.md
  • examples/saas-billing-golden-path/vitest.config.ts
  • packages/admin-react/src/tests/AdminPanel.spec.ts
  • packages/cli/src/tests/contractsCheck.spec.ts
  • packages/cli/src/tests/contractsDiff.spec.ts
  • packages/entitlements-core/README.md
  • packages/entitlements-core/package.json
  • packages/entitlements-core/src/index.ts
  • packages/entitlements-core/src/libs/EntitlementGuard.ts
  • packages/entitlements-core/src/libs/EntitlementManager.ts
  • packages/entitlements-core/src/libs/EntitlementRequirement.ts
  • packages/entitlements-core/src/libs/decorators/RequireEntitlement.ts
  • packages/entitlements-core/src/libs/interfaces.ts
  • packages/entitlements-core/src/libs/problems/EntitlementProblems.ts
  • packages/entitlements-core/src/libs/types.ts
  • packages/entitlements-core/src/tests/EntitlementGuard.spec.ts
  • packages/entitlements-core/src/tests/EntitlementIntegration.spec.ts
  • packages/entitlements-core/src/tests/EntitlementManager.spec.ts
  • packages/framework-routes/src/__tests__/compiler.spec.ts
  • packages/openapi-spec/src/libs/emitOpenAPI.ts
  • packages/openapi-spec/src/tests/emitOpenAPI.spec.ts
  • packages/protocols-core/src/index.ts
  • packages/protocols-core/src/libs/ContractGraph.ts
  • packages/protocols-core/src/libs/ContractGraphConsumerCoverage.ts
  • packages/protocols-core/src/libs/ContractGraphDiff.ts
  • packages/protocols-core/src/libs/ContractGraphSnapshot.ts
  • packages/protocols-core/src/libs/sharedTypes.ts
  • packages/protocols-core/src/tests/ContractGraph.spec.ts
  • packages/protocols-core/src/tests/helpers/test-decorators.ts
  • packages/rpc-codegen/src/tests/codegen.spec.ts
  • public-api-surface.snapshot.json

Comment thread packages/entitlements-core/src/libs/EntitlementGuard.ts Outdated
Comment thread packages/entitlements-core/src/libs/EntitlementGuard.ts Outdated
Comment thread packages/entitlements-core/src/libs/EntitlementGuard.ts
Comment thread packages/entitlements-core/src/libs/EntitlementRequirement.ts
Comment thread packages/protocols-core/src/libs/ContractGraphDiff.ts
Comment thread packages/protocols-core/src/tests/helpers/test-decorators.ts
Comment thread public-api-surface.snapshot.json Outdated
@kang-heewon
kang-heewon force-pushed the fix/920-entitlement-guard branch from cfbbaf5 to f222a24 Compare June 20, 2026 07:50
@kang-heewon
kang-heewon force-pushed the fix/920-entitlement-guard branch from f222a24 to f881684 Compare June 20, 2026 08:03

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/entitlements-core/src/libs/EntitlementGuard.ts`:
- Around line 71-95: The createGuardInput method call at line 72 is executed
outside the try-catch block, which means any EntitlementDeniedProblem thrown
during input validation and preprocessing bypasses the recordDenied call that is
inside the catch block. This results in missing denied telemetry and audit logs.
Move the createGuardInput call inside the try block (before the
entitlementManager.check call) so that exceptions thrown during input creation
are also caught and properly recorded through the recordDenied method.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 37e716dc-c433-4d57-9350-68f8985ee80a

📥 Commits

Reviewing files that changed from the base of the PR and between ee82263 and 1f3f51f.

📒 Files selected for processing (20)
  • .changeset/entitlement-guard-contracts.md
  • examples/saas-billing-golden-path/vitest.config.ts
  • packages/admin-react/src/tests/AdminPanel.spec.ts
  • packages/cli/src/tests/contractsCheck.spec.ts
  • packages/cli/src/tests/contractsDiff.spec.ts
  • packages/cli/vitest.config.ts
  • packages/entitlements-core/README.md
  • packages/entitlements-core/package.json
  • packages/entitlements-core/src/index.ts
  • packages/entitlements-core/src/libs/EntitlementGuard.ts
  • packages/entitlements-core/src/libs/EntitlementManager.ts
  • packages/entitlements-core/src/libs/EntitlementRequirement.ts
  • packages/entitlements-core/src/libs/decorators/RequireEntitlement.ts
  • packages/entitlements-core/src/libs/interfaces.ts
  • packages/entitlements-core/src/libs/problems/EntitlementProblems.ts
  • packages/entitlements-core/src/libs/types.ts
  • packages/entitlements-core/src/tests/EntitlementGuard.spec.ts
  • packages/entitlements-core/src/tests/EntitlementIntegration.spec.ts
  • packages/entitlements-core/src/tests/EntitlementManager.spec.ts
  • packages/entitlements-core/src/tests/EntitlementRequirement.spec.ts

Comment thread packages/entitlements-core/src/libs/EntitlementGuard.ts
@kang-heewon
kang-heewon force-pushed the fix/920-entitlement-guard branch from 1f3f51f to 488d6ff Compare June 21, 2026 04:29
@kang-heewon
kang-heewon force-pushed the fix/920-entitlement-guard branch from 488d6ff to 99b7927 Compare June 21, 2026 04:42
@kang-heewon
kang-heewon merged commit 9c1bc2e into trunk Jun 21, 2026
8 checks passed
@kang-heewon
kang-heewon deleted the fix/920-entitlement-guard branch June 21, 2026 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[entitlements-core] Entitlement Guard를 route/service 경계에 연결한다

1 participant